#include "Player.h"
#include "STGEngine.h"
#include <tolua++.h>
#include <lua.hpp>
#include <lualib.h>
#include <lauxlib.h>
#include "Defs.h"
GameInst* CPlayer::createInstance(const std::string &name) {
    GameInst *pInst = new CPlayerInst(this, name);
    mInstances.push_back(pInst);
    return pInst;
}

CPlayerInst::CPlayerInst(CPlayer *pObject, const std::string &name)
: CCreatureInst(pObject, name) {
    
}

void CPlayerInst::update( float dt )
{
    CCreatureInst::update(dt);
}
void CPlayer::loadConfigScript() {
    lua_State *L = static_cast<CSTGEngine*>(CSTGEngine::getSingletonPtr())->lua();
    if (luaL_dofile(L, mScriptName.c_str())) 
        lua_error(L);

    GET_LUA_FLOAT(L, "power", mPower);
    GET_LUA_FLOAT(L, "speed", mSpeed);
    GET_LUA_FLOAT(L, "defence", mDefence);
    GET_LUA_FLOAT(L, "life", mLife);
    GET_LUA_FLOAT(L, "mana", mMana);
    GET_LUA_STRING(L, "texture", mTexture);
    
}
